// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;

@ccclass
export default class ControlMirror extends cc.Component {

    @property({tooltip: "旋转的角度"})
    rotateGross: number = 0;

    //获取初始的角度
    initAngle = 0;
    onLoad () {
        this.initAngle = this.node.angle;
    }

    start () {

    }

    nodeRotate(dir){
        this.node.stopAllActions();
        let nowAngle = this.node.angle;
        let tagAngle = dir == 1 ? this.initAngle + this.rotateGross : this.initAngle;
        let difference = tagAngle - nowAngle;
        let time = Math.abs(difference) / 180;
        console.log(dir, tagAngle, time);
        this.node.runAction(
            cc.rotateTo(time, tagAngle)
        )
    }


    // update (dt) {}
}
